package com.mydemo.design_pattern.action_type.iterator_pattern.impl;

import com.mydemo.design_pattern.action_type.iterator_pattern.Iterator;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: NameIterator, v1.0 2019-09-23 10:26 liming1 Exp $
 */
public class NameIterator implements Iterator {

    private int index;
    private Object[] store;

    public NameIterator(Object[] obj) {
        this.store = obj;
    }

    @Override
    public boolean hasNext() {
        if (store == null || index >= this.store.length) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        if (this.hasNext()) {
            return this.store[index++];
        }
        return null;
    }
}
